package com.situ.spring.aop;

import com.situ.spring.service.ICourseService;
import com.situ.spring.service.impl.CourseServiceImpl;
import org.junit.Test;

public class AOPDemo {
    @Test
    public void test1() {
        DongShiZhang dongShiZhang = new DongShiZhang();
        IQianzi mishu = new MiShu(dongShiZhang);
        mishu.qianzi();
    }

    @Test
    public void test2() {
        //目标对象
        DongShiZhang dongShiZhang = new DongShiZhang();
        //给目标对象创建代理对象
        IQianzi proxy = (IQianzi) ProxyFactory.getProxyInstance(dongShiZhang);
        proxy.qianzi();
    }

    @Test
    public void test3() {
        CourseServiceImpl courseService = new CourseServiceImpl();
        ICourseService proxy = (ICourseService) ProxyFactory.getProxyInstance(courseService);
        proxy.selectAll();
        proxy.selectById();
    }
}
